*----------------------------------------------------------------------------------------------------------	* 
* RESEARCHERS:		Emtiaz Hritan, Tim Bruckner									   							*
* PROGRAMMED BY:	Emtiaz Hritan																			*
* DESCRIPTION:      The Politics of Birth: How Local Representation Shapes Maternal-Infant Outcomes				 						 	*
* CREATED:			Oct. 14, 2025																		   	*
* LAST MODIFIED:	Jan. 27, 2025													       					*
*----------------------------------------------------------------------------------------------------------	*



clear all
set more off
* Set local paths
* Set this local datapath equal to the folder location for data
	local datapath "C:\Users\name\Replication Files Politics of Birth\Data"
* Set this local outputpath equal to the folder location for outcome like tables
	local outputpath "C:\Users\name\Replication Files Politics of Birth\Outcome"

* Install necessary packages
ssc install reghdfe
ssc install ftools
ssc install grstyle, replace
ssc install palettes, replace
ssc install colrspace, replace
ssc install ppmlhdfe, replace 
ssc install jwdid, replace 
ssc install csdid, replace 
ssc install drdid, replace 
ssc install did_imputation, replace
ssc install frause, replace
frause mpdta.dta, clear
ssc install hdfe, replace 
ssc install event_plot, replace
ssc install addplot, replace

************************************************************************
** Figures 1, 2, 3: Event-study estimates of the effect of the first electoral victory of a female, Black, Hispanic, or Asian candidate in county-level elections on birth outcomes:
************************************************************************


*==============================================================
* Event studies (OLS with reghdfe) for four treatments
*==============================================================
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe imr o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe imr o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe imr o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe imr o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Neonatal Mortality per 1,000", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.5)1) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))	

	
	
	
**************************************************ptb_rate*********************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe ptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe ptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe ptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe ptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Preterm Birth (<37w) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.5)1) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
	
	
	
	
	
	
	
*************************************************vptb_rate************************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Very Preterm (<32w) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-0.50(.25)0.50) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
	
	
	
	
	
***************************************eptb_rate**************************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe eptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe eptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe eptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe eptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Extremely Preterm (<28w) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-0.20(.10)0.20) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
	
	
	
	
**************************************************lbw_rate*********************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe lbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe lbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe lbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe lbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Low Birthweight (<2500g) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.5(.25).5) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))			
	
	
	
	
	
**************************************************vlbw_rate*********************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vlbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vlbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vlbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe vlbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Very Low Birthweight (<1500g) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.20(.10)0.20) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))			
		
	

	
	
	
**************************************************csection_rate*********************************************************************************************	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe csection_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe csection_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe csection_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe csection_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Cesarean Section Rate %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1.5(.5)1.5) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))	
	
	
**************************************************periviable_rate*********************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe periviable_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe periviable_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe periviable_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe periviable_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Periviable Birth (20–<28w) %", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-0.10(.05)0.10) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
	
	
	
	
	
	
**************************************************births_gestation_all*********************************************************************************************	
	
	
	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_gestation_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_gestation_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_gestation_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_gestation_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Mean Gestational Age (weeks)", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-0.10(0.05)0.10) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
	
	
	
	
		
	
**************************************************births_previsit_all*********************************************************************************************	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_previsit_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_previsit_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_previsit_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe births_previsit_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Mean Prenatal Visits", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.5)1) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
		
	
	
	
	
	
**************************************************infant_mortality_rate*********************************************************************************************	
	
	
	
	
clear all
eststo clear
* Load panel once
use "`datapath'\final.dta", clear
xtset county_fips year

* Sample rule used in your analysis
drop if births_all < 100

* 1-year induction (treatment starts the calendar year after first win)
gen first_female   = year_female   + 1 if !missing(year_female)
gen first_black    = year_black    + 1 if !missing(year_black)
gen first_hispanic = year_hispanic + 1 if !missing(year_hispanic)
gen first_asian    = year_asian    + 1 if !missing(year_asian)


*========================
* (A) First FEMALE
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated = !missing(first_female)
gen time_to_treat = year - first_female if ever_treated
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe infant_mortality_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_female

*========================
* (B) First BLACK
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe infant_mortality_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_black

*========================
* (C) First HISPANIC
*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_hs = !missing(first_hispanic)
gen time_to_treat = year - first_hispanic if ever_treated_hs
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe infant_mortality_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_hispanic

*========================
* (D) First ASIAN

*========================
capture drop time_to_treat F*event L*event
gen byte ever_treated_ai = !missing(first_asian)
gen time_to_treat = year - first_asian if ever_treated_ai
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

quietly reghdfe infant_mortality_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
estimates store ES_asian

*========================
* Combined plot (all four)
*========================


// Combine all 4 plots using the stored estimates
event_plot ES_female ES_black ES_hispanic ES_asian, ///
	stub_lag(L#event L#event L#event L#event) stub_lead(F#event F#event F#event F#event) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Infant Mortality per 1,000", size(medlarge)) ///
		xtitle("Years since first win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.5)1) ///
		legend(pos(6) order( 1 "Female"  3 "Black" 5 "Hispanic" 7 "Asian") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))		
		
		
	
*========================
* End
*========================	
	

	
	
	
************************************************************************
** Figures A8, A9, A10: Event-study estimates of the effect of the first electoral victory of a Black candidate in county-level elections on birth outcomes:
************************************************************************	
	
	
clear all 
use "`datapath'\final.dta"

* First treated year = election year + 1 (1-yr induction)
cap drop first_treat
gen first_treat = year_black + 1 if !missing(year_black)
replace first_treat = 0 if missing(first_treat)   // 0 = never-treated

* Let's drop counties with low births and low NH Black births
drop if births_all < 100
drop if births_NHB < 100	

* Panel id + time
xtset county_fips year

                        
*************Callaway and Sant'Anna (2021)*********************


*Not yet treated 
csdid imr, ivar(county_fips) time(year) gvar(first_treat) notyet 
estat all
estat event, window(-7 7) estore(cs1)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on neonatal mortality per 1,000")

csdid ptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs2)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on preterm birth (<37w) %")

csdid vptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs3)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on very preterm (<32w) %")

csdid eptb_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs4)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on extremely preterm (<28w) %")

csdid lbw_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs5)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on low birthweight (<2500g) %")

csdid vlbw_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs6)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on very low birthweight (<1500g) %")

csdid csection_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs7)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on cesarean section rate %")

csdid periviable_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs8)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on periviable birth (20–<28w) %")

csdid births_gestation_all, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs9)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on mean gestational age (weeks)")

csdid births_previsit_all, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs10)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on mean prenatal visits")

csdid infant_mortality_rate, ivar(county_fips) time(year) gvar(first_treat) notyet
estat all
estat event, window(-7 7) estore(cs11)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on infant mortality per 1,000") 





*************Callaway and Sant'Anna (2021)*********************


*Never treated 
csdid imr, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever1)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on neonatal mortality per 1,000")

csdid ptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever2)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on preterm birth (<37w) %")

csdid vptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever3)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on very preterm (<32w) %")

csdid eptb_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever4)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on extremely preterm (<28w) %")

csdid lbw_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever5)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on low birthweight (<2500g) %")

csdid vlbw_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever6)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on very low birthweight (<1500g) %")

csdid csection_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever7)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on cesarean section rate %")

csdid periviable_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever8)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on periviable birth (20–<28w) %")

csdid births_gestation_all, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever9)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on mean gestational age (weeks)")

csdid births_previsit_all, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever10)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on mean prenatal visits")

csdid infant_mortality_rate, ivar(county_fips) time(year) gvar(first_treat) 
estat all
estat event, window(-7 7) estore(csnever11)
csdid_plot, xtitle("Years since first Black win") ytitle("Average effect on infant mortality per 1,000") 




* Using did_imputation package based on Borusyak, Kirill, Xavier Jaravel, and Jann Spiess (2023). "Revisiting Event Study Designs: Robust and Efficient Estimation," Working paper.
cap drop Ei
gen Ei = first_treat
replace Ei = . if Ei==0

* BJS Event Study Graphs
did_imputation imr county_fips year Ei, autosample
did_imputation imr county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs1 
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on neonatal mortality per 1,000") xlabel(-7(1)7 7))

did_imputation ptb_rate county_fips year Ei, autosample
did_imputation ptb_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs2
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on preterm birth (<37w) %") xlabel(-7(1)7 7))

did_imputation vptb_rate county_fips year Ei, autosample
did_imputation vptb_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs3
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on very preterm (<32w) %") xlabel(-7(1)7 7))

did_imputation eptb_rate county_fips year Ei, autosample
did_imputation eptb_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs4
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on extremely preterm (<28w) %") xlabel(-7(1)7 7))

did_imputation lbw_rate county_fips year Ei, autosample
did_imputation lbw_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs5
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on low birthweight (<2500g) %") xlabel(-7(1)7 7))


did_imputation vlbw_rate county_fips year Ei, autosample
did_imputation vlbw_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs6
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on very low birthweight (<1500g) %") xlabel(-7(1)7 7))

did_imputation csection_rate county_fips year Ei, autosample
did_imputation csection_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs7
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on cesarean section rate %") xlabel(-7(1)7 7))


did_imputation periviable_rate county_fips year Ei, autosample
did_imputation periviable_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs8
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on periviable birth (20–<28w) %") xlabel(-7(1)7 7))


did_imputation births_gestation_all county_fips year Ei, autosample
did_imputation births_gestation_all county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs9
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on mean gestational age (weeks)") xlabel(-7(1)7 7))


did_imputation births_previsit_all county_fips year Ei, autosample
did_imputation births_previsit_all county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs10
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on mean prenatal visits") xlabel(-7(1)7 7))


did_imputation infant_mortality_rate county_fips year Ei, autosample
did_imputation infant_mortality_rate county_fips year Ei, horizons(0/7) pretrend(7) minn(0) autosample
estimates store bjs11
event_plot, default_look graph_opt(xtitle("Years since first Black win") ytitle("Average effect on infant mortality per 1,000") xlabel(-7(1)7 7))
	
	
	
* OLS Event study

* 1-year induction (treatment starts the calendar year after first win)

gen first_black    = year_black    + 1 if !missing(year_black)

capture drop time_to_treat F*event L*event
gen byte ever_treated_b = !missing(first_black)
gen time_to_treat = year - first_black if ever_treated_b
forvalues l = 0/9 {
    gen F`l'event = (time_to_treat == -`l')
}
gen F10event = (time_to_treat <= -10)
forvalues l = 0/9 {
    gen L`l'event = (time_to_treat == `l')
}
gen L10event = (time_to_treat >= 10)

reghdfe imr o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols1

reghdfe ptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols2

reghdfe vptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols3

reghdfe eptb_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols4

reghdfe lbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols5

reghdfe vlbw_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols6

reghdfe csection_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols7

reghdfe periviable_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols8

reghdfe births_gestation_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols9

reghdfe births_previsit_all o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols10

reghdfe infant_mortality_rate o.F1event F2event-F10event L*event [aw=births_all], ///
    absorb(county_fips year) vce(cluster county_fips)
	
	// plotting the coeffients
        event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter) ///
                graph_opt(xtitle("Years since first Black win") ytitle("OLS coefficients") xlabel(-10(1)10 10))
estimates store ols11



	
	
*************************Combined Graphs**********************	

// Combine all 3 plots using the stored estimates
event_plot cs1 ols1 bjs1, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Neonatal Mortality per 1,000", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1.5(1)1.5) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))	
		
	
graph export "`outputpath'\imr.eps", replace


// Combine all 3 plots using the stored estimates
event_plot cs2 ols2 bjs2, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Preterm Birth (<37w) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1.5(1)1.5) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\ptb.eps", replace


// Combine all 3 plots using the stored estimates
event_plot cs3 ols3 bjs3, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Very Preterm (<32w) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.5(.5).5) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\vptb.eps", replace



// Combine all 3 plots using the stored estimates
event_plot cs4 ols4 bjs4, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Extremely Preterm (<28w) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.25(.25).25) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\eptb.eps", replace



// Combine all 3 plots using the stored estimates
event_plot cs5 ols5 bjs5, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Low Birthweight (<2500g) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.50)1) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\lb.eps", replace

// Combine all 3 plots using the stored estimates
event_plot cs6 ols6 bjs6, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Very Low Birthweight (<1500g) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.5(.25).5) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\vlb.eps", replace

// Combine all 3 plots using the stored estimates
event_plot cs7 ols7 bjs7, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Cesarean Section Rate %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-2(1)2) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\cs.eps", replace

// Combine all 3 plots using the stored estimates
event_plot cs8 ols8 bjs8, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Periviable Birth (20–<28w) %", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.25(.25).25) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\periviable.eps", replace


// Combine all 3 plots using the stored estimates
event_plot cs9 ols9 bjs9, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Mean Gestational Age (weeks)", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-.25(.25).25) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\ga.eps", replace


// Combine all 3 plots using the stored estimates
event_plot cs10 ols10 bjs10, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Mean Prenatal Visits", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-1(.5)1) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\prenatal.eps", replace


// Combine all 3 plots using the stored estimates
event_plot cs11 ols11 bjs11, ///
	stub_lag(Tp# L#event tau#) stub_lead(Tm#  F#event pre#) plottype(scatter) ciplottype(rcap) ///
	together perturb(-0.325(0.13)0.325) trimlead(5) trimlag(5) noautolegend ///
	graph_opt(title("Event Study Estimators: Average Effect on Infant Mortality per 1,000", size(medlarge)) ///
		xtitle("Years since first Black win") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(-2(1)2) ///
		legend(pos(6) order( 1 "Callaway & Sant'Anna"  3 "OLS TWFE" 5 "Borusyak et al.") rows(1) region(style(none))) ///
/// the following lines replace default_look with something more elaborate
		xline(-1, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///
	) ///
	lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///
	lag_opt2(msymbol(Oh) color(navy)) lag_ci_opt2(color(navy)) ///
	lag_opt3(msymbol(Dh) color(forest_green)) lag_ci_opt3(color(forest_green)) 	lag_opt4(msymbol(Th) color(purple)) lag_ci_opt4(color(purple))
	


graph export "`outputpath'\infant.eps", replace
*--------------------------------------------------------------------------
* END
*--------------------------------------------------------------------------	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	